﻿#region 命名空间

using System;
using System.IO;
using System.Text;
using System.Web;
using System.Web.UI.WebControls;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Collections;
using WinnerCMS.Data;
using WinnerCMS.Common;
using WinnerCMS.Model;
using System.Text.RegularExpressions;

#endregion

namespace WinnerCMS.BLL
{
    /// <summary>
    /// ResultManage 的摘要说明。
    /// </summary>
    public partial class VoteManage
    {
        private static readonly VoteDal MyDal = new VoteDal();


        public Vote Load(int id)
        {
            return MyDal.Load(id);
        }

        /// <summary>
        /// 取得投票结果
        /// </summary>
        /// <param name="voteId"></param>
        /// <returns></returns>
        public IList<VoteChoice> GetResult(string voteId)
        {
            int i;
            if (int.TryParse(voteId, out i) == false)
            {
                ErrClass.IndexErrRedirect("参数错误!");
            }

            Vote model = MyDal.Load(i);
            if (model == null)
            {
                ErrClass.IndexErrRedirect("该投票项目不存在或者没有通过审核！");
            }

            return new VoteChoiceDal().GetResult(int.Parse(voteId));
        }

        #region 投票

        /// <summary>
        /// 投票
        /// </summary>
        /// <param name="info">投票信息</param> 
        [ExceptionCall]
        public Result PostVote(Vote info)
        {
            Result res = new Result();

            new VoteChoiceDal().VoteThis(info);

            return res;
        }

        #endregion

        #region 显示投票

        /// <summary>
        /// 显示投票
        /// </summary>
        /// <param name="id"></param>
        [Cache("VoteManage.ShowVote_{@p0}")]
        public Vote ShowVote(int id)
        {
            return MyDal.ShowVote(id);
        }

        #endregion
    }
}